package com.ijunfu.study.jdk.jdk8.date;

import java.time.LocalDate;

/**
 * @Title : LocalDate 常用API 示例
 * @Remarks:
 * @Author : Weizhiguo
 * @Version: 1.0.0
 * @Date : 2022-04-30
 */
public class LocalDateDemo {

    public static void main(String[] args) {
//        baseDemo();

        LocalDate now = LocalDate.now();    // 2022-04-30

        LocalDate localDate = LocalDate.of(2022, 12, 31);

        System.out.println(now.isAfter(localDate));             // false
        System.out.println(now.isBefore(localDate));            // true
        System.out.println(now.isEqual(localDate));             // false
    }

    private static void baseDemo() {
        // 1. 创建指定的日期
        LocalDate localDate = LocalDate.of(2022, 04, 30);
        System.out.println(localDate);

        //2. 获取当前日期
        LocalDate now = LocalDate.now();
        System.out.println(now);
        System.out.println(now.getYear());                  // 年
        System.out.println(now.getMonth().getValue());      // 月
        System.out.println(now.getDayOfMonth());            // 日
        System.out.println(now.getDayOfWeek().getValue());  // 星期
    }
}
